package weaver.interfaces.jjy.duss.hr;

import com.sap.mw.jco.JCO;
import weaver.interfaces.jjy.duss.util.SAPConnPool;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: ecology-9-demo
 * @description: 加班费拆分接口明细B
 * @author: Dusongsong
 * @create: 2019-12-31
 */
public class ZFM_HR_029B {
    public Map execute(List<Map<String,String>> mapList) {
       // Map<String, String> map = new HashMap<String, String>();
        SAPConnPool SAPConn = new SAPConnPool();
        JCO.Client myConnection = SAPConn.getConnection();
        JCO.Function bapi = SAPConn.excuteBapi("ZFM_HR_029B");
        JCO.ParameterList input = bapi.getImportParameterList();//输入参数和结构处理
        JCO.ParameterList inputtable = bapi.getTableParameterList();//输入表的处理

        //入参为表
        JCO.Table t1 = inputtable.getTable("IT_TABLE");
        for (Map<String, String> map :mapList) {
            t1.appendRow();
            t1.setValue(map.get("NUMID"), "NUMID");            //唯一标识
            t1.setValue(map.get("GJAHR"), "GJAHR");            //年度
            t1.setValue(map.get("JRLX"), "JRLX");              //节日类型
            t1.setValue(map.get("PERNR"), "PERNR");            //人员编码
            t1.setValue(map.get("GRSBJRJBF"), "GRSBJRJBF");    //个人上报节日加班费
            t1.setValue(map.get("GRSBXJJBF"), "GRSBXJJBF");    //个人上报现金加班费
        }


        //执行函数
        myConnection.execute(bapi);
        JCO.ParameterList out = bapi.getExportParameterList();//输出参数和结构处理
        JCO.ParameterList Table00 = bapi.getTableParameterList();//输出表的处理

        //返回处理结果以及日志
        JCO.Table stu = Table00.getTable("IT_TABLE");
        Map<String, String> mapreturn = new HashMap<>();
        String flag = (String) stu.getValue("ZFLAG");
        String message = (String) stu.getValue("ZMESG");
        mapreturn.put("flag",flag);
        mapreturn.put("message",message);
        System.out.println("返回结果："+ mapreturn);
        JCO.releaseClient(myConnection);
        return mapreturn;
    }
}
